package com.crm.service.impl.couponManager;

import com.crm.dao.mapper.couponManager.CouponProductMapper;
import com.crm.dao.mapper.customMapper.couponCustomManager.CouponProductCustomMapper;
import com.crm.model.entity.couponManager.CouponProduct;
import com.crm.model.entity.couponManager.CouponProductExample;
import com.crm.service.couponManager.CouponProductDbService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @Author renshaorong
 * @Date 2021/11/16
 */
@Service
public class CouponProductDbServiceImpl implements CouponProductDbService {

    @Autowired
    private CouponProductCustomMapper couponProductCustomMapper;
    @Autowired
    private CouponProductMapper couponProductMapper;

    @Override
    public boolean insertBatch(List<CouponProduct> couponProducts) {
        return couponProductCustomMapper.insertBatch(couponProducts) > 0;
    }

    @Override
    public List<Map<String,String>> selectProductIdListByCouponId(String couponId) {
        return couponProductCustomMapper.selectProductIdListByCouponId(couponId);
    }

    @Override
    public void removeByCouponId(String chsCustomerCouponId) {
        CouponProductExample couponProductExample = new CouponProductExample();
        CouponProductExample.Criteria criteria = couponProductExample.createCriteria();
        criteria.andChsCustomerCouponIdEqualTo(chsCustomerCouponId);
        couponProductMapper.deleteByExample(couponProductExample);
    }
}
